﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Web;
using Travasto.Model;

namespace Travasto.Web.Areas.Admin.Commands
{
    public class AddTourCommand
    {
        public TravastoDbContext DbContext { get; set; }
        public Tour Tour { get; set; }

        public AddTourCommand(Tour tour, TravastoDbContext context)
        {
            this.Tour = tour;
            this.DbContext = context;
        }

        public void Execute()
        {
            // Save tags
            this.Tour.Tags = (new AddTagsCommand(this.Tour.Tags, DbContext)).Execute();

            // Save tours
            DbContext.Tours.Add(Tour);
            DbContext.SaveChanges();
        }
    }
}